﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
	<title>延续子流程</title>
	 <link href="../../Comm/Style/CommStyle.css" rel="stylesheet" type="text/css" />
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet"  type="text/css" />
    <link href="../../Scripts/easyUI/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>

	<base target="_self" />
	<script type="text/javascript">

	    //页面启动函数.
	    $(function () {
	        $("#Msg").html("<img src=../../Img/loading.gif />&nbsp;正在加载,请稍后......");

	        //求出来已经设置的延续子流程.
	        var nodeID = GetQueryString("FK_Node");
	        var orgNo = GetQueryString("OrgNo");

	        //查询出来数据.
	        var sql = "SELECT A.No AS SortNo, A.Name as SORTNAME, b.No AS NO, b.Name AS FLOWNAME ";
	        sql += " FROM WF_FlowSort a, WF_Flow b WHERE (A.OrgNo='" + orgNo + "' OR A.ParentNo='" + orgNo + "') AND A.No=B.FK_FlowSort ";
	        sql += " ORDER BY A.Idx, b.Idx ";

	        //获得要增加的流程集合.
	        var dt = DBAccess.RunSQLReturnTable(sql);
	        console.log(dt);

	        var html = "";
	        for (var i = 0; i < dt.length; i++) {

	            var en = dt[i];
	            console.log(en);

	            html += "<tr>";
	            html += "<td>" + en.SORTNAME + "</td>";
	            html += "<td>" + en.FLOWNAME + "</td>";
	            html += "<td><a href=\"javascript:CheckIt('" + en.NO + "');\" >选择</a></td>";
	            html += "</tr>";
	        }

	        $("#Table1 tr:last").after(html);

	    });


	    function CheckIt(flowNo) {
	        var nodeID = GetQueryString("FK_Node");

	        var ens = new Entities("BP.WF.Template.NodeYGFlows");
	        ens.Retrieve("FK_Node", nodeID, "FK_Flow", flowNo);

	        if (ens.length == 1) {
	            alert("该流程已经存在");
	            return;
	        }

	        var en = new Entity("BP.WF.Template.NodeYGFlow");
	        en.FK_Flow = flowNo;
	        en.FK_Node = GetQueryString("FK_Node");
	        var myen= en.Insert();

	        window.location.href = '../../Comm/RefFunc/EnOnly.htm?EnName=BP.WF.Template.NodeYGFlow&PKVal=' + myen.OID;

	        //alert('当前流程已经加入了延续流程中.');
	    }
         
    </script>
</head>
<body>
	<table id="Table1" style="width: 100%">
		
        <caption>请选择一个子流程</caption>

        <tr>
        <th>流程类别</th>
        <th>名称</th>
        <th>选择</th>
        </tr>
		 
	</table>
     
</body>
</html>
